package cn.ctyun.ipush.dao;

import cn.ctyun.ipush.model.DataSourceModel;
import cn.ctyun.ipush.model.LogModel;
import com.dexcoder.dal.JdbcDao;
import com.dexcoder.dal.build.Criteria;
import com.dexcoder.dal.spring.page.PageControl;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: user
 * Date: 16-7-15
 * Time: 上午9:11
 * To change this template use File | Settings | File Templates.
 */
@Component
public class LogDao {
    @Autowired
    private JdbcDao jdbcDao;

    @Autowired
    private PageControl pageControl;


    /**
     * 保存
     *
     * @param logModel
     */
    public void save(LogModel logModel) {
        jdbcDao.save(logModel);
    }

    /**
     * 查询单个,根据ID
     *
     * @param logModelId
     * @return
     */
    public LogModel querySingleResult(String logModelId) {
        if (StringUtils.isEmpty(logModelId))
            throw new RuntimeException("logModel 主键id 必须设置");
        Criteria criteria = Criteria.select(LogModel.class).where("logModelId", new Object[]{logModelId});
        return jdbcDao.querySingleResult(criteria);
    }


    /**
     * 查询所有
     *
     * @return
     */
    public List<LogModel> queryList(LogModel logModel) {
        return jdbcDao.queryList(logModel);
    }
}

